﻿package mortal.game.view.npc
{
    import fl.data.*;
    import flash.utils.*;
    import mortal.game.view.npc.data.*;
    import mortal.game.view.task.data.*;

    public class NpcTaskChooseCache extends Object
    {
        private var _chosenDic:Dictionary;

        public function NpcTaskChooseCache()
        {
            this._chosenDic = new Dictionary();
            return;
        }// end function

        public function parseForChoose(param1:TaskInfo, param2:String) : DataProvider
        {
            var _loc_6:NpcChooseData = null;
            if (param2 == null || param2.indexOf("{choose,") < 0)
            {
                return null;
            }
            param2 = param2.substr(param2.lastIndexOf("{"));
            param2 = param2.substr(0, param2.lastIndexOf("}"));
            var _loc_3:* = param2.split(",");
            var _loc_4:* = new DataProvider();
            var _loc_5:int = 1;
            while (_loc_5 < _loc_3.length)
            {
                
                _loc_6 = new NpcChooseData();
                _loc_6.info = param1;
                _loc_6.text = _loc_3[_loc_5];
                _loc_6.index = _loc_5 - 1;
                _loc_6.isAnsweredWrong = this.getChosen(param1.stask.code, param1.curStep, (_loc_5 - 1));
                _loc_4.addItem(_loc_6);
                _loc_5++;
            }
            return _loc_4;
        }// end function

        public function setChosen(param1:TaskInfo, param2:int) : void
        {
            this._chosenDic[this.getKey(param1.stask.code, param1.curStep, param2)] = true;
            return;
        }// end function

        public function getChosen(param1:int, param2:int, param3:int) : Boolean
        {
            return this._chosenDic[this.getKey(param1, param2, param3)];
        }// end function

        public function getKey(param1:int, param2:int, param3:int) : String
        {
            return param1.toString() + "_" + param2.toString() + "_" + param3.toString();
        }// end function

    }
}
